package cn.chencaiju.day03;

import org.junit.Test;

public class DoubleDimensinalArray {
	public void printArrayTest1(int[][] scores) {
		for (int i = 0; i < scores.length; i++) {
			for (int j = 0; j < scores[i].length; j++) {
				System.out.print(scores[i][j] + " ");
			}
			System.out.println();
		}
	}

	@Test
	public void testPrintArray1() {
		int[][] scores = { { 11, 12, 13, 14 }, { 21, 22, 23, 24 }, { 31, 32, 33, 34 } };
		printArrayTest1(scores);
	}

	public void printArrayTest2(int[][] scores) {
		for (int i = scores.length - 1; i >= 0; i--) {
			for (int j = 0; j < scores[i].length; j++) {
				System.out.print(scores[i][j] + " ");
			}
			System.out.println();
		}

	}

	@Test
	public void testPrintArray2() {
		int[][] scores = { { 11, 12, 13, 14 }, { 21, 22, 23, 24 }, { 31, 32, 33, 34 } };
		printArrayTest2(scores);
	}

	public void printArrayTest3(int[][] scores) {
		for (int i = scores.length - 1; i >= 0; i--) {
			for (int j = scores[i].length - 1; j >= 0; j--) {
				System.out.print(scores[i][j] + " ");
			}
			System.out.println();
		}
	}

	@Test
	public void testPrintArray3() {
		int[][] scores = { { 11, 12, 13, 14 }, { 21, 22, 23, 24 }, { 31, 32, 33, 34 } };
		printArrayTest3(scores);
	}

	public void printArrayTest4(int[][] scores) {
		int j = 0, i = scores.length - 1;
		while (true) {
			System.out.print(scores[i][j] + " ");
			i--;
			if (i < 0) {
				i = scores.length - 1;
				j++;
				if (j >= scores[i].length)
					break;
				System.out.println();
			}
		}
	}

	@Test
	public void testPrintArray4() {
		int[][] scores = { { 11, 12, 13, 14 }, { 21, 22, 23, 24 }, { 31, 32, 33, 34 } };
		printArrayTest4(scores);
	}
}
